Follow up models for interactions

#define soubgroups by AOB (monolingually-raised fall under >10)
hsg_winsorized_cleaned <-read_excel('hsg_winsorized_cleaned.xlsx')


hsg_winsorized_cleaned$group <- with(hsg_winsorized_cleaned, case_when(
  aob_english <= 3 ~ "0-3",
  aob_english >= 4 & aob_english <= 6 ~ "4-6",
  aob_english >= 7 & aob_english <= 10 ~ "7-9",
  aob_english > 10 ~ ">10"
))

hsg_winsorized_cleaned$group <- factor(hsg_winsorized_cleaned$group,
                                       levels = c("0-3", "4-6", "7-9", ">10"))
#participant counts per sobgroup
hsg_winsorized_cleaned %>%
  group_by(group) %>%
  summarise(n_participants = n_distinct(subjectid))
## # A tibble: 4 × 2
##   group n_participants
##   <fct>          <int>
## 1 0-3               19
## 2 4-6               22
## 3 7-9               13
## 4 >10               32
hsg_winsorized_cleaned$group <- factor(
  hsg_winsorized_cleaned$group,
  levels = c("0-3", "4-6", "7-9", ">10")  # Ensure correct order
)

hsg_winsorized_cleaned$trial_order_c <- scale(hsg_winsorized_cleaned$Trial_Index_, center = TRUE, scale = FALSE)
hsg_winsorized_cleaned$adj_length_c <- scale(hsg_winsorized_cleaned$length, center = TRUE, scale = FALSE)
hsg_winsorized_cleaned$proficiency_c <- scale(hsg_winsorized_cleaned$proficiency, center = TRUE, scale = FALSE)

no_cue_data <- hsg_winsorized_cleaned %>%
  filter(condition == "no_cue", IA_ID == 6)

log_total_data <- no_cue_data %>%
  filter(IA_DWELL_TIME > 0) %>%
  mutate(log_total = as.numeric(log(IA_DWELL_TIME)))

log_total_03 <- log_total_data %>%
  filter(group == "0-3")

m_nocue_total_03 <- lmer(
  log_total ~ match * proficiency_c +
    trial_order_c + adj_length_c +
    (1 + match | subjectid) +
    (1 | item),
  data = log_total_03,
  REML = FALSE,
  control = lmerControl(optimizer = "bobyqa")
)
## boundary (singular) fit: see help('isSingular')
summary(m_nocue_total_03)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log_total ~ match * proficiency_c + trial_order_c + adj_length_c +  
##     (1 + match | subjectid) + (1 | item)
##    Data: log_total_03
## Control: lmerControl(optimizer = "bobyqa")
## 
##      AIC      BIC   logLik deviance df.resid 
##    468.3    508.8   -223.1    446.3      283 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.03113 -0.63495  0.03762  0.67494  2.74267 
## 
## Random effects:
##  Groups    Name          Variance Std.Dev. Corr
##  item      (Intercept)   0.004278 0.06540      
##  subjectid (Intercept)   0.032718 0.18088      
##            matchmismatch 0.004645 0.06816  1.00
##  Residual                0.240110 0.49001      
## Number of obs: 294, groups:  item, 64; subjectid, 19
## 
## Fixed effects:
##                               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  5.865e+00  7.551e-02  3.285e+01  77.666   <2e-16
## matchmismatch                1.088e-01  6.864e-02  5.304e+01   1.585   0.1189
## proficiency_c               -1.855e-02  9.894e-03  2.154e+01  -1.875   0.0745
## trial_order_c               -1.080e-03  7.975e-04  2.795e+02  -1.354   0.1769
## adj_length_c                 7.085e-02  2.934e-02  6.392e+01   2.414   0.0186
## matchmismatch:proficiency_c  9.877e-03  1.015e-02  8.365e+01   0.974   0.3331
##                                
## (Intercept)                 ***
## matchmismatch                  
## proficiency_c               .  
## trial_order_c                  
## adj_length_c                *  
## matchmismatch:proficiency_c    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) mtchms prfcn_ trl_r_ adj_l_
## matchmsmtch -0.275                            
## proficncy_c  0.395 -0.127                     
## trial_rdr_c -0.043  0.057 -0.014              
## adj_lngth_c -0.479  0.011 -0.004 -0.011       
## mtchmsmtc:_ -0.154  0.437 -0.287  0.035  0.084
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
confint(m_nocue_total_03, parm = "beta_", method = "Wald")
##                                    2.5 %       97.5 %
## (Intercept)                  5.716635839 6.0126318962
## matchmismatch               -0.025731065 0.2433522516
## proficiency_c               -0.037938626 0.0008454140
## trial_order_c               -0.002642845 0.0004833598
## adj_length_c                 0.013333491 0.1283597666
## matchmismatch:proficiency_c -0.010007930 0.0297612757
log_total_46 <- log_total_data %>%
  filter(group == "4-6")

m_nocue_total_46 <- lmer(
  log_total ~ match * proficiency_c +
    trial_order_c + adj_length_c +
    (1 + match | subjectid) +
    (1 | item),
  data = log_total_46,
  REML = FALSE,
  control = lmerControl(optimizer = "bobyqa")
)

summary(m_nocue_total_46)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log_total ~ match * proficiency_c + trial_order_c + adj_length_c +  
##     (1 + match | subjectid) + (1 | item)
##    Data: log_total_46
## Control: lmerControl(optimizer = "bobyqa")
## 
##      AIC      BIC   logLik deviance df.resid 
##    586.0    627.7   -282.0    564.0      317 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.5086 -0.7022 -0.0355  0.7695  2.4002 
## 
## Random effects:
##  Groups    Name          Variance Std.Dev. Corr
##  item      (Intercept)   0.004977 0.07055      
##  subjectid (Intercept)   0.020774 0.14413      
##            matchmismatch 0.014859 0.12190  0.55
##  Residual                0.298726 0.54656      
## Number of obs: 328, groups:  item, 64; subjectid, 22
## 
## Fixed effects:
##                               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  5.757e+00  7.084e-02  2.808e+01  81.273  < 2e-16
## matchmismatch                3.781e-01  7.691e-02  1.971e+01   4.916 8.68e-05
## proficiency_c               -2.035e-02  1.393e-02  2.031e+01  -1.461  0.15936
## trial_order_c               -1.366e-03  8.498e-04  3.170e+02  -1.607  0.10895
## adj_length_c                 6.221e-02  3.119e-02  6.853e+01   1.995  0.05008
## matchmismatch:proficiency_c  5.819e-02  1.724e-02  1.861e+01   3.374  0.00326
##                                
## (Intercept)                 ***
## matchmismatch               ***
## proficiency_c                  
## trial_order_c                  
## adj_length_c                .  
## matchmismatch:proficiency_c ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) mtchms prfcn_ trl_r_ adj_l_
## matchmsmtch -0.319                            
## proficncy_c  0.363 -0.206                     
## trial_rdr_c  0.032  0.018  0.054              
## adj_lngth_c -0.488 -0.125  0.072 -0.007       
## mtchmsmtc:_ -0.124  0.452 -0.430 -0.011 -0.102
confint(m_nocue_total_46, parm = "beta_", method = "Wald")
##                                    2.5 %       97.5 %
## (Intercept)                  5.618559419 5.8962494069
## matchmismatch                0.227332608 0.5288118078
## proficiency_c               -0.047648754 0.0069525543
## trial_order_c               -0.003031428 0.0002995657
## adj_length_c                 0.001077718 0.1233481251
## matchmismatch:proficiency_c  0.024390051 0.0919801553
# Generate predicted values from the models
eff_03 <- ggpredict(m_nocue_total_03, terms = c("proficiency_c [all]", "match"))
eff_46 <- ggpredict(m_nocue_total_46, terms = c("proficiency_c [all]", "match"))

# Plot the interaction
#0-3
ggplot(eff_03, aes(x = x, y = predicted, color = group)) +
  geom_line(size = 1.2) +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill = group), alpha = 0.2, color = NA) +
  labs(
    title = "Grammaticality × Proficiency (AOB 0–3)",
    x = "Proficiency (centered)",
    y = "Predicted Log Total Time",
    color = "Match Condition",
    fill = "Match Condition"
  ) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
  theme_minimal(base_size = 14)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

#4-6
ggplot(eff_46, aes(x = x, y = predicted, color = group)) +
  geom_line(size = 1.2) +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill = group), alpha = 0.2, color = NA) +
  labs(
    title = "Grammaticality × Proficiency (AOB 4–6)",
    x = "Proficiency (centered)",
    y = "Predicted Log Total Time",
    color = "Match Condition",
    fill = "Match Condition"
  ) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
  theme_minimal(base_size = 14)

log_gp_data <- no_cue_data %>%
  filter(IA_REGRESSION_PATH_DURATION > 0) %>%
  mutate(log_gp = as.numeric(log(IA_REGRESSION_PATH_DURATION)))

log_gp_03 <- log_gp_data %>%
  filter(group == "0-3")

m_nocue_gp_03 <- lmer(
  log_gp ~ match * proficiency_c +
    trial_order_c + adj_length_c +
    (1 + match | subjectid) +
    (1 | item),
  data = log_gp_03,
  REML = FALSE,
  control = lmerControl(optimizer = "bobyqa")
)
## boundary (singular) fit: see help('isSingular')
summary(m_nocue_gp_03)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log_gp ~ match * proficiency_c + trial_order_c + adj_length_c +  
##     (1 + match | subjectid) + (1 | item)
##    Data: log_gp_03
## Control: lmerControl(optimizer = "bobyqa")
## 
##      AIC      BIC   logLik deviance df.resid 
##    527.9    568.5   -253.0    505.9      283 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2714 -0.7370 -0.0570  0.5214  3.3943 
## 
## Random effects:
##  Groups    Name          Variance Std.Dev. Corr
##  item      (Intercept)   0.00000  0.0000       
##  subjectid (Intercept)   0.00000  0.0000       
##            matchmismatch 0.01661  0.1289    NaN
##  Residual                0.32020  0.5659       
## Number of obs: 294, groups:  item, 64; subjectid, 19
## 
## Fixed effects:
##                               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  5.814e+00  6.555e-02  2.564e+02  88.701   <2e-16
## matchmismatch                2.883e-02  8.115e-02  2.965e+01   0.355   0.7249
## proficiency_c               -1.829e-02  7.953e-03  2.384e+02  -2.300   0.0223
## trial_order_c               -3.110e-04  9.045e-04  2.636e+02  -0.344   0.7312
## adj_length_c                -2.288e-02  3.162e-02  2.520e+02  -0.724   0.4700
## matchmismatch:proficiency_c -8.260e-04  1.235e-02  2.975e+01  -0.067   0.9471
##                                
## (Intercept)                 ***
## matchmismatch                  
## proficiency_c               *  
## trial_order_c                  
## adj_length_c                   
## matchmismatch:proficiency_c    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) mtchms prfcn_ trl_r_ adj_l_
## matchmsmtch -0.527                            
## proficncy_c  0.369 -0.294                     
## trial_rdr_c -0.071  0.055 -0.020              
## adj_lngth_c -0.598  0.013 -0.009  0.014       
## mtchmsmtc:_ -0.284  0.451 -0.645  0.035  0.081
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
confint(m_nocue_gp_03, parm = "beta_", method = "Wald")
##                                    2.5 %       97.5 %
## (Intercept)                  5.685581489  5.942518155
## matchmismatch               -0.130214445  0.187876719
## proficiency_c               -0.033879265 -0.002704297
## trial_order_c               -0.002083889  0.001461868
## adj_length_c                -0.084861669  0.039100610
## matchmismatch:proficiency_c -0.025034572  0.023382622
log_gp_46 <- log_gp_data %>%
  filter(group == "4-6")

m_nocue_gp_46 <- lmer(
  log_gp ~ match * proficiency_c +
    trial_order_c + adj_length_c +
    (1 + match | subjectid) +
    (1 | item),
  data = log_gp_46,
  REML = FALSE,
  control = lmerControl(optimizer = "bobyqa")
)

summary(m_nocue_gp_46)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log_gp ~ match * proficiency_c + trial_order_c + adj_length_c +  
##     (1 + match | subjectid) + (1 | item)
##    Data: log_gp_46
## Control: lmerControl(optimizer = "bobyqa")
## 
##      AIC      BIC   logLik deviance df.resid 
##    580.3    622.1   -279.2    558.3      317 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2990 -0.6781 -0.0782  0.5024  3.2686 
## 
## Random effects:
##  Groups    Name          Variance Std.Dev. Corr
##  item      (Intercept)   0.01342  0.1158       
##  subjectid (Intercept)   0.02149  0.1466       
##            matchmismatch 0.02199  0.1483   0.54
##  Residual                0.28325  0.5322       
## Number of obs: 328, groups:  item, 64; subjectid, 22
## 
## Fixed effects:
##                               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  5.629e+00  7.319e-02  3.216e+01  76.902   <2e-16
## matchmismatch                2.127e-01  8.162e-02  2.212e+01   2.606   0.0161
## proficiency_c               -2.314e-02  1.380e-02  2.288e+01  -1.676   0.1073
## trial_order_c               -8.126e-04  8.416e-04  3.173e+02  -0.966   0.3350
## adj_length_c                 5.298e-02  3.260e-02  6.327e+01   1.625   0.1092
## matchmismatch:proficiency_c  4.729e-02  1.755e-02  1.625e+01   2.695   0.0158
##                                
## (Intercept)                 ***
## matchmismatch               *  
## proficiency_c                  
## trial_order_c                  
## adj_length_c                   
## matchmismatch:proficiency_c *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) mtchms prfcn_ trl_r_ adj_l_
## matchmsmtch -0.296                            
## proficncy_c  0.350 -0.176                     
## trial_rdr_c  0.028  0.019  0.054              
## adj_lngth_c -0.498 -0.116  0.069 -0.006       
## mtchmsmtc:_ -0.100  0.435 -0.377 -0.011 -0.097
confint(m_nocue_gp_46, parm = "beta_", method = "Wald")
##                                    2.5 %       97.5 %
## (Intercept)                  5.485367453 5.7722862803
## matchmismatch                0.052757585 0.3727204868
## proficiency_c               -0.050195440 0.0039174439
## trial_order_c               -0.002462069 0.0008368452
## adj_length_c                -0.010928565 0.1168796876
## matchmismatch:proficiency_c  0.012894579 0.0816873869
# Generate predicted values from the models
eff_03_gp <- ggpredict(m_nocue_gp_03, terms = c("proficiency_c [all]", "match"))
eff_46_gp <- ggpredict(m_nocue_gp_46, terms = c("proficiency_c [all]", "match"))

# Plot the interaction
#0-3
ggplot(eff_03_gp, aes(x = x, y = predicted, color = group)) +
  geom_line(size = 1.2) +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill = group), alpha = 0.2, color = NA) +
  labs(
    title = "AOB 0–3",
    x = "Proficiency (centered)",
    y = "Predicted Log Go-Past Time",
    color = "Match Condition",
    fill = "Match Condition"
  ) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
  theme_minimal(base_size = 14)

#4-6
ggplot(eff_46_gp, aes(x = x, y = predicted, color = group)) +
  geom_line(size = 1.2) +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill = group), alpha = 0.2, color = NA) +
  labs(
    title = "AOB 4–6",
    x = "Proficiency (centered)",
    y = "Predicted Log Go-Past Time",
    color = "Match Condition",
    fill = "Match Condition"
  ) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
  theme_minimal(base_size = 14)

#CUE CONDITION
#Total time
cue_data <- hsg_winsorized_cleaned %>%
  filter(condition == "cue", IA_ID == 7)

log_total_cue <- cue_data %>%
  filter(IA_DWELL_TIME > 0) %>%
  mutate(log_total = as.numeric(log(IA_DWELL_TIME)))

log_total_cue$group_binned <- case_when(
  log_total_cue$group %in% c("0-3", "4-6") ~ "0-6",
  log_total_cue$group == "7-9" ~ "7-9",
  TRUE ~ NA_character_  # excludes >10 from this comparison
)

log_total_cue$group_binned <- factor(
  log_total_cue$group_binned,
  levels = c("0-6", "7-9")
)

subset_data_06 <- log_total_cue %>%
  filter(group_binned %in% c("0-6"))

m1_cue_total_06 <- lmer(log_total ~ match * proficiency_c +
               trial_order_c + adj_length_c +
               (1 + match | subjectid) +
               (1 + match | item),
               data = subset_data_06,
               REML = FALSE,
               control = lmerControl(optimizer = "bobyqa"))
## boundary (singular) fit: see help('isSingular')
summary(m1_cue_total_06)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log_total ~ match * proficiency_c + trial_order_c + adj_length_c +  
##     (1 + match | subjectid) + (1 + match | item)
##    Data: subset_data_06
## Control: lmerControl(optimizer = "bobyqa")
## 
##      AIC      BIC   logLik deviance df.resid 
##   1010.5   1068.0   -492.2    984.5      601 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.32824 -0.69851  0.00855  0.73549  2.47657 
## 
## Random effects:
##  Groups    Name          Variance Std.Dev. Corr 
##  item      (Intercept)   0.006922 0.08320       
##            matchmismatch 0.008900 0.09434  -1.00
##  subjectid (Intercept)   0.034179 0.18487       
##            matchmismatch 0.019667 0.14024  0.06 
##  Residual                0.261637 0.51150       
## Number of obs: 614, groups:  item, 64; subjectid, 41
## 
## Fixed effects:
##                               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  5.764e+00  5.485e-02  4.441e+01 105.082  < 2e-16
## matchmismatch                3.426e-01  5.421e-02  3.598e+01   6.320 2.61e-07
## proficiency_c               -2.064e-02  8.429e-03  4.111e+01  -2.449  0.01868
## trial_order_c                2.614e-04  5.802e-04  5.796e+02   0.450  0.65254
## adj_length_c                 5.919e-02  2.101e-02  9.769e+01   2.817  0.00587
## matchmismatch:proficiency_c  3.310e-02  9.663e-03  4.413e+01   3.425  0.00134
##                                
## (Intercept)                 ***
## matchmismatch               ***
## proficiency_c               *  
## trial_order_c                  
## adj_length_c                ** 
## matchmismatch:proficiency_c ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) mtchms prfcn_ trl_r_ adj_l_
## matchmsmtch -0.445                            
## proficncy_c  0.385 -0.178                     
## trial_rdr_c  0.026 -0.007 -0.015              
## adj_lngth_c -0.478  0.065 -0.044 -0.024       
## mtchmsmtc:_ -0.173  0.416 -0.433  0.053  0.047
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
confint(m1_cue_total_06, parm = "beta_", method = "Wald")
##                                     2.5 %       97.5 %
## (Intercept)                  5.6563580513  5.871369424
## matchmismatch                0.2363609870  0.448855380
## proficiency_c               -0.0371591852 -0.004120219
## trial_order_c               -0.0008758114  0.001398543
## adj_length_c                 0.0180020298  0.100372999
## matchmismatch:proficiency_c  0.0141602447  0.052039896
subset_data_79 <- log_total_cue %>%
  filter(group_binned %in% c("7-9"))

m1_cue_total_79 <- lmer(log_total ~ match * proficiency_c +
               trial_order_c + adj_length_c +
               (1 + match | subjectid) +
               (1 + match | item),
               data = subset_data_79,
               REML = FALSE,
               control = lmerControl(optimizer = "bobyqa"))
## boundary (singular) fit: see help('isSingular')
summary(m1_cue_total_79)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log_total ~ match * proficiency_c + trial_order_c + adj_length_c +  
##     (1 + match | subjectid) + (1 + match | item)
##    Data: subset_data_79
## Control: lmerControl(optimizer = "bobyqa")
## 
##      AIC      BIC   logLik deviance df.resid 
##    346.3    389.4   -160.2    320.3      190 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.70023 -0.71303 -0.04487  0.76010  2.29333 
## 
## Random effects:
##  Groups    Name          Variance  Std.Dev. Corr 
##  item      (Intercept)   0.0114607 0.10705       
##            matchmismatch 0.0114607 0.10705  -1.00
##  subjectid (Intercept)   0.0211586 0.14546       
##            matchmismatch 0.0005851 0.02419  -1.00
##  Residual                0.2659766 0.51573       
## Number of obs: 203, groups:  item, 48; subjectid, 13
## 
## Fixed effects:
##                               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  5.695e+00  9.398e-02  2.285e+01  60.599  < 2e-16
## matchmismatch                5.020e-01  9.519e-02  9.988e+01   5.274 7.75e-07
## proficiency_c               -5.151e-02  1.372e-02  1.593e+01  -3.754 0.001744
## trial_order_c               -8.195e-04  1.013e-03  1.996e+02  -0.809 0.419432
## adj_length_c                 9.745e-03  4.241e-02  1.081e+02   0.230 0.818704
## matchmismatch:proficiency_c  5.419e-02  1.511e-02  1.373e+02   3.587 0.000464
##                                
## (Intercept)                 ***
## matchmismatch               ***
## proficiency_c               ** 
## trial_order_c                  
## adj_length_c                   
## matchmismatch:proficiency_c ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) mtchms prfcn_ trl_r_ adj_l_
## matchmsmtch -0.421                            
## proficncy_c  0.393 -0.359                     
## trial_rdr_c -0.001 -0.138  0.015              
## adj_lngth_c -0.473 -0.266  0.157  0.070       
## mtchmsmtc:_ -0.248  0.548 -0.624 -0.081 -0.095
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
confint(m1_cue_total_06, parm = "beta_", method = "Wald")
##                                     2.5 %       97.5 %
## (Intercept)                  5.6563580513  5.871369424
## matchmismatch                0.2363609870  0.448855380
## proficiency_c               -0.0371591852 -0.004120219
## trial_order_c               -0.0008758114  0.001398543
## adj_length_c                 0.0180020298  0.100372999
## matchmismatch:proficiency_c  0.0141602447  0.052039896
# Generate predicted values from the models
eff_06_total <- ggpredict(m1_cue_total_06, terms = c("proficiency_c [all]", "match"))
eff_79_total <- ggpredict(m1_cue_total_79, terms = c("proficiency_c [all]", "match"))

# Plot the interaction
#0-3
ggplot(eff_06_total, aes(x = x, y = predicted, color = group)) +
  geom_line(size = 1.2) +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill = group), alpha = 0.2, color = NA) +
  labs(
    title = "AOB 0–6",
    x = "Proficiency (centered)",
    y = "Predicted Log Total Time",
    color = "Match Condition",
    fill = "Match Condition"
  ) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
  theme_minimal(base_size = 14)

#4-6
ggplot(eff_79_total, aes(x = x, y = predicted, color = group)) +
  geom_line(size = 1.2) +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill = group), alpha = 0.2, color = NA) +
  labs(
    title = "AOB 7–9",
    x = "Proficiency (centered)",
    y = "Predicted Log Total Time",
    color = "Match Condition",
    fill = "Match Condition"
  ) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
  theme_minimal(base_size = 14)